# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=sparta
pkgver=21.b0a4514
pkgrel=3
groups=('blackarch' 'blackarch-scanner' 'blackarch-cracker'
        'blackarch-fingerprint' 'blackarch-networking')
pkgdesc='Python GUI application which simplifies network infrastructure penetration testing by aiding the penetration tester in the scanning and enumeration phase.'
arch=('any')
url='http://sparta.secforce.com/'
license=('GPL3')
depends=('python2' 'python2-pyqt4' 'python2-lxml' 'impacket' 'python2-elixir')
makedepends=('git')
source=("git+https://github.com/SECFORCE/$pkgname.git"
        'dirty_fix.patch')
sha512sums=('SKIP'
            '53c3eb1ab2bc72742c967ab9b230aa3d49f4558a8a82210d04086a5c10ecb420c4d4399d8ba9ebe645bebbe355a4c4697fca7ac6f94628b5d2a1053dd5de8c28')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  patch -Np1 -i ../dirty_fix.patch
}

package() {
  cd "$srcdir/sparta"

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" doc/* README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

